home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C++ / Applications / Mic-1 v1.0 / Project and Source / Source / mic_data_path.h < prev    next >
Text File  |  1996-05-17  |  5KB  |  177 lines

  1. #ifndef _MIC_DATA_PATH_
  2. #define _MIC_DATA_PATH_
  3.  
  4. #include <iostream.h>
  5. #include "mic_main.h"
  6.  
  7. class MARClass;
  8. class MBRClass;
  9. class ScratchPadClass;
  10. class ALUClass;
  11. class AMUXClass;
  12. class ShifterClass;
  13. class A_LatchClass;
  14. class B_LatchClass;
  15.  
  16. class MARClass
  17. {
  18.     private:
  19.         unsigned short word;
  20.         short mar_enabled;
  21.     public:
  22.         MARClass() {word = 0; mar_enabled = false;}
  23.         void input_B_Latch (unsigned short newWord) {if (mar_enabled) word = (newWord & 0x0FFF);}
  24.         void input_MIR (short enable) {mar_enabled = enable;}
  25.         void output (Mic_1_Class& Mic);
  26.         friend ostream& operator << (ostream& s, MARClass& m);
  27. };
  28.  
  29. class MBRClass
  30. {
  31.     private:
  32.         unsigned short word;
  33.         short read_enabled;
  34.         short write_enabled;
  35.         short mbr_enabled;
  36.     public:
  37.         MBRClass() {word = 0; read_enabled = false;
  38.             write_enabled = false; mbr_enabled = false;}
  39.         void input_Memory (unsigned short newWord);
  40.         void input_Shifter (unsigned short newWord);
  41.         void input_MIR_read (short read) {read_enabled = read;}
  42.         void input_MIR_write (short write) {write_enabled = write;}
  43.         void input_MIR_enable (short enable) {mbr_enabled = enable;}
  44.         void output (Mic_1_Class& Mic);
  45.         friend ostream& operator << (ostream& s, MBRClass& m);
  46. };
  47.  
  48. class ScratchPadClass
  49. {
  50.     private:
  51.         unsigned short registers[16];
  52.         unsigned short shifter_word;
  53.         unsigned short selection_a;
  54.         unsigned short selection_b;
  55.         unsigned short selection_c;
  56.         short c_enabled;
  57.     public:
  58.         ScratchPadClass();
  59.         void input_MIR_enable (short newEnable) {c_enabled = newEnable;}
  60.         void input_MIR_A (Mic_1_Class& Mic, unsigned short a) {selection_a = a; output(Mic);}
  61.         void input_MIR_B (Mic_1_Class& Mic, unsigned short b) {selection_b = b; output(Mic);}
  62.         void input_MIR_C (unsigned short c) {selection_c = c;}
  63.         void input_Shifter (unsigned short new_shifter_word)
  64.         {
  65.             shifter_word = new_shifter_word;
  66.             if (c_enabled)
  67.                 registers[selection_c] = shifter_word;
  68.         }
  69.         void output (Mic_1_Class& Mic);
  70.         friend ostream& operator << (ostream& s, ScratchPadClass& scratch);
  71. };
  72.  
  73. class AMUXClass
  74. {
  75.     private:
  76.         short from_mbr;
  77.         unsigned short a_latch_word;
  78.         unsigned short mbr_word;
  79.     public:
  80.         AMUXClass() {from_mbr = false; a_latch_word = false; mbr_word = 0;}
  81.         void input_MBR (Mic_1_Class& Mic, unsigned short new_mbr_word)
  82.         {
  83.             mbr_word = new_mbr_word;
  84.             if (from_mbr)
  85.                 output(Mic);
  86.         }
  87.         void input_A_Latch (Mic_1_Class& Mic, unsigned short new_a_latch_word)
  88.         {
  89.             a_latch_word = new_a_latch_word;
  90.             if (!from_mbr)
  91.                 output(Mic);
  92.         }
  93.         void input_MIR (short new_from_mbr) {from_mbr = new_from_mbr;}
  94.         void output (Mic_1_Class& Mic);
  95.         friend ostream& operator << (ostream& s, AMUXClass& a);
  96. };
  97.  
  98. class ALUClass
  99. {
  100.     private:
  101.         short check;    // to prevent unnecessary work, check makes sure both pipes have been received
  102.         unsigned short b_latch_word;
  103.         unsigned short amux_word;
  104.         unsigned short operation;
  105.         short negative;
  106.         short zero;
  107.     public:
  108.         ALUClass() {check = b_latch_word = amux_word = operation = negative = zero = 0;}
  109.         void input_AMUX(Mic_1_Class& Mic, unsigned short new_amux_word)
  110.         {
  111.             amux_word = new_amux_word;
  112.             if ((operation == 2) || (operation == 3))
  113.             {
  114.                 output(Mic);
  115.                 check = 0;
  116.             }
  117.             else
  118.             {
  119.                 if (check == 1)
  120.                 {output(Mic); check = 0;}
  121.                 else (check = 1);
  122.             }
  123.         }
  124.         void input_B_Latch(Mic_1_Class& Mic, unsigned short new_b_latch_word)
  125.         {
  126.             b_latch_word = new_b_latch_word;
  127.             if ((operation == 0) || (operation == 1))
  128.             {
  129.                 if (check == 1)
  130.                 {output(Mic); check = 0;}
  131.                 else (check = 1);
  132.             }
  133.             else
  134.             {
  135.                 check = 0;
  136.             }
  137.         }
  138.         void input_MIR(unsigned short new_operation) {operation = new_operation;}
  139.         void output (Mic_1_Class& Mic);
  140.         friend ostream& operator << (ostream& s, ALUClass& a);
  141. };
  142.  
  143. class ShifterClass
  144. {
  145.     private:
  146.         unsigned short word;
  147.         unsigned short option;
  148.     public:
  149.         void input_ALU (Mic_1_Class& Mic, unsigned short newWord);
  150.         void input_MIR (unsigned short newOption) {option = newOption;}
  151.         void output (Mic_1_Class& Mic);
  152.         friend ostream& operator << (ostream& s, ShifterClass& a);
  153. };
  154.  
  155. class A_LatchClass
  156. {
  157.     private:
  158.         unsigned short word;
  159.     public:
  160.         A_LatchClass() {word = 0;}
  161.         void input_ScratchPad (unsigned short newWord) {word = newWord;}
  162.         void output (Mic_1_Class& Mic);
  163.         friend ostream& operator << (ostream& s, A_LatchClass& a);
  164. };
  165.  
  166. class B_LatchClass
  167. {
  168.     private:
  169.         unsigned short word;
  170.     public:
  171.         B_LatchClass() {word = 0;}
  172.         void input_ScratchPad (unsigned short newWord) {word = newWord;}
  173.         void output (Mic_1_Class& Mic);
  174.         friend ostream& operator << (ostream& s, B_LatchClass& b);
  175. };
  176.  
  177. #endif